﻿<template>
  <a-modal
    title="新增诊断输入"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="个人编码" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入个人编码" v-decorator="['psnNo']" />
        </a-form-item>
        <a-form-item label="诊断类别字典诊断类别(diag_type) " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入诊断类别字典诊断类别(diag_type) " v-decorator="['diagtype']" />
        </a-form-item>
        <a-form-item label="诊断排序号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入诊断排序号 " v-decorator="['diagsrtno']" />
        </a-form-item>
        <a-form-item label="诊断代码- " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入诊断代码- " v-decorator="['diagcode']" />
        </a-form-item>
        <a-form-item label="诊断名称- " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入诊断名称- " v-decorator="['diagname']" />
        </a-form-item>
        <a-form-item label="诊断科室 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入诊断科室 " v-decorator="['diagdept']" />
        </a-form-item>
        <a-form-item label="诊断医生编码 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入诊断医生编码 " v-decorator="['disedorno']" />
        </a-form-item>
        <a-form-item label="诊断医生姓名 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入诊断医生姓名 " v-decorator="['disedorname']" />
        </a-form-item>
        <a-form-item label="诊断时间yyyy-MM-dd HH:mm:ss " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入诊断时间yyyy-MM-dd HH:mm:ss " v-decorator="['diagtime']" />
        </a-form-item>
        <a-form-item label="有效标志 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入有效标志 " v-decorator="['valiflag']" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
  import {
    Nitf6201InputDiseinfoAdd
  } from '@/api/modular/main/Nitf6201InputDiseinfoManage'

  export default {
    data () {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 }
        },
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
    },
    methods: {
      // 初始化方法
      add (record) {
        this.visible = true
      },
      /**
       * 提交表单
       */
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
              }
            }
            Nitf6201InputDiseinfoAdd(values).then((res) => {
              if (res.success) {
                this.$message.success('新增成功')
                this.confirmLoading = false
                this.$emit('ok', values)
                this.handleCancel()
              } else {
                this.$message.error('新增失败：' + JSON.stringify(res.message))
              }
            }).finally((res) => {
              this.confirmLoading = false
            })
          } else {
            this.confirmLoading = false
          }
        })
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
    }
  }
</script>
